import { Navigate, useLocation } from 'react-router-dom'
import { isAuth } from '@/utils'

export const AuthRoute = ({ children }) => {
  const location = useLocation()
  if (!isAuth()) {
    return <Navigate to='/login' state={{ from: location }} />
  }

  return children
}
